Вот полный код проверки емайлов:
function check_email()
{
var email = $("#email").val();
if (email == "")
{
$("#email_error").show();
return false;
}
else
{
if (validateEmail(email))
{
$.ajax({
type : "POST",
url : "email_pass_check.php", // url îòïðàâëÿåì email ìåòîäîì POST
data : "email="+ email,
success : function(result) {
// åñëè email â áàçå åñòü, òî îøèáêó íå âûâîäèì
if (result == 1) {
$("#email_error").hide();
return true;
} else {
// åñëè email â áàçå íåò, òî âûâîäèì îøèáêó
$("#email_error").show();
$("#email_error").html("The email address you entered does not belong to any account. You can login using any email associated with your account. Make sure that it is typed correctly.");
return false;
}
},
});
}
else
{
$("#email_error").show();
$("#email_error").html("Please enter an email address in the following format [email]ani@lookingschools.com[/email]");
return false;
}
}
}
function validateEmail(email) {
var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
return re.test(email);
}